layui.use(['element', 'table', 'jquery', 'laydate', 'form'], function () {
    var element = layui.element;
    var table = layui.table;
    var laydate = layui.laydate;
    var form = layui.form;
    laydate.render();
    $(function () {
        let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
        let userId = userInfo.id;
            let noSignMember = myAjax("/user/user/getNoSignTeamMemberByUser", "get", {"userId": userId});
            sessionStorage.setItem("teamMember", JSON.stringify(noSignMember));
            let data = JSON.parse(sessionStorage.getItem("teamMember")).data;
            console.log(data);
            if (JSON.stringify(data) == '[]') {
                $(".layui-form").html("<div style='text-align: center; padding:11% 0;'><i class='layui-icon' style='line-height:20rem; font-size:20rem; color: #393D50;'>&#xe609;</i><p style='font-size: 20px; font-weight: 300; color: #999;'>暂无未打卡成员</p></div>");
            } else {
                $("tbody").html("");
                $.each(data, function (i, user) {
                    if (user.name != null)
                        user.name = user.code + "(" + user.name + ")";
                    else
                        user.name = user.code;
                    $("tbody").append("<tr><td><label class='layui-form-label '><input class='code_name' hidden='hidden' value='" + user.code + "'>" + user.name + "</label></td><td><div class='layui-input-inline'><select class='sign_status' id='" + user.id + "' lay-filter='sign_status'><option value='已到'>已到</option><option value='迟到'>迟到</option><option value='请假'>请假</option><option value='旷课'>旷课</option></select></div></td><td><div class='layui-input-inline'><input id='late_time_" + user.id + "' class='layui-input late_time' type='text' style='display: none'/></div></td></tr>");
                    layui.laydate.render({
                        elem: "#late_time_" + user.id,
                        type: 'datetime'
                    });

                });
                form.render();
                form.on('select(sign_status)', function (obj) {
                    console.log(obj);
                    console.log(obj.elem.id);
                    if (obj.value == '迟到') {
                        $("#late_time_" + obj.elem.id).removeAttr("style");
                    } else
                        $("#late_time_" + obj.elem.id).attr("style", "display: none");
                    form.render();
                })
            }
    })
})
